package cn.blog.utils;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import cn.blog.dto.LoginUser;

/**
 * 获取当前在线用户信息
 * 
 * @author 偶尔有点困
 * @date 2018年5月5日
 */
public class UserUtil {

	public static LoginUser getCurrentUser() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		if (authentication != null) {
			return (LoginUser) authentication.getPrincipal();
		}

		return null;
	}

}